import React, { useState, useEffect } from "react";
import { Space, Table, Tag, Button } from "antd";
import type { TableProps } from "antd";
import axios from "axios";
const Index: React.FC = () => {
  interface DataType {
    key: string;
    name: string;
    age: number;
    address: string;
  }
  const [userList, setUserList] = useState<any>([]);
  const columns: TableProps["columns"] = [
    {
      title: "头像",
      dataIndex: "info",
      key: "info",
      render: (_, record) => (
        <div>
          <img src={record.info} />
        </div>
      ),
    },
    {
      title: "用户名",
      dataIndex: "username",
      key: "username",
    },
    {
      title: "权限",
      dataIndex: "row",
      key: "row",
    },
     
  ];

  const data: DataType[] = userList;
  const render=()=>{
    axios.get("/api/userList").then((resp) => {
      setUserList(resp.data.userList);
    });
  }
  useEffect(() => {
    render()
  }, []);
  return (
    <div>
      <Table columns={columns} dataSource={data} />
    </div>
  );
};
export default Index;
